# A Nearly Similar Powerful Test for Mediation: Code

This repository contains the code accompanying the paper "A Nearly Similar Powerful Test for Mediation", written by [Kees Jan van Garderen](https://www.uva.nl/en/profile/g/a/k.j.vangarderen/k.j.vangarderen.html) and [Noud van Giersbergen](https://www.uva.nl/profiel/g/i/n.p.a.vangiersbergen/n.p.a.vangiersbergen.html), and published in the [Review of Economics and Statistics](https://direct.mit.edu/rest).

## Code

The Stata file `2_Table3.do` within the `code` folder generates the $t$-ratios for Table 3 in the paper. It assumes the presence of the two files `gstyping.dta` and `1_measures.do` from the replication repository of the paper by Alan, S., Ertac, S. and Mumcu, I. (2018) Replication Data for: "Gender Stereotypes in the Classroom and Effects on Achievement", https://doi.org/10.7910/DVN/FGBZCK, Harvard Dataverse.

The Julia file `Table-4.jl` generates the rejection frequencies shown in Table 4 of the paper.

The R code `gFunctions.R` within the `code` folder can be used to determine the critical values of the optimal $g_{opt}(t)$ and $g_{1.2}(t)$-functions as reported in the paper and shown in the online Appendix.

## Outputs

The results of the Stata-do file for Table 3 are saved as `Table3_Girls_Reg1.csv` (estimates and t-ratios for regression (1) of the paper) and `Table3_Girls_Reg2.csv` (estimates and t-ratios for regression (2) of the paper).

The file `Table-4-RF-REP1000000.csv` contains the results for Table 4, generated by the Julia script for $n=50, 100, 250$, and $500$. Due to page space restrictions, Table 4 does not show the results for $n=250$.

## Software

The results were obtained using Stata/MP 18.0 and Julia v1.10 running on Windows 11.